package com.类加载顺序;

//父类
class Foo {
	int i = 1;

	Foo() {
		System.out.println(i);
		int x = getValue();
		System.out.println(x);
	}

	{
		i = 2;
	}

	protected int getValue() {
		return i;
	}
}

// 子类
class Bar extends Foo {
	int j = 1;

	Bar() {
		j = 2;
	}

	{
		j = 3;
	}

	@Override
	protected int getValue() {
		System.out.println("子类getValue被调用");
		return j;
	}
}

public class ConstructorExample {
	public static void main(String... args) {
		Bar bar = new Bar();
		System.out.println(bar.getValue());
	}
}
/**
 *  2
	子类getValue被调用
	0
	子类getValue被调用
	2

	//Foo类构造函数的等价变换：
   Foo() {
       i = 1;
       i = 2;
       System.out.println(i);
       int x = getValue();
       System.out.println(x);
   }


	//Bar类构造函数的等价变换
   Bar() {
       Foo();
       j = 1;
       j = 3;
       j = 2
   }
 * */